#{extends 'main.html' /}
#{if user == editedUser}
    #{set title:'Edit your profile' /}
#{/if}
#{else}
    #{set title:'Edit user' /}
#{/else}
#{set hasForm: true /}

#{if user == editedUser}
    <h1>Edit your profile</h1>
#{/if}
#{else}
    <h1>Edit #{user editedUser/}´s profile</h1>
#{/else}

<ul class="nav nav-tabs">
    <li class="active"><a href="#" onclick="return false;" title="General Information">Information</a></li>
    <li><a href="@{LoggedInUsers.passwordForm(editedUser.userName)}" title="Change password">Change password</a></li>
</ul>

#{form action: @LoggedInUsers.edit(editedUser.userName), class: "form-horizontal"}

<fieldset>
    <legend>Edit profile</legend>
    <div class="control-group #{errorClassBootstrap 'email'/}">
        <label class="control-label" for="email">Email</label>
        <div class="controls">
            <input name="email" type="text" value="${flash.email ?: editedUser.email}" maxlength="${util.Util.VARCHAR_SIZE}"/>
            <span class="help-inline">​#{error 'email'/}</span>
            #{if editedUser?.isEmailConfirmationNeeded()}
            <span class="help-inline">(New email ${editedUser.emailToConfirm} not confirmed)</span>
            #{/if}
            #{if !user?.isAdmin && !"true".equals(play.Play.configuration.get("register.skip.email"))}
            <span class="help-block">If you modify your email address, you will receive a message to validate it.</span>
            #{/if}
        </div>
    </div>
    <div class="control-group #{errorClassBootstrap 'firstName'/}">
        <label class="control-label" for="firstName">First name</label>
        <div class="controls">
            <input name="firstName" type="text" value="${flash.firstName ?: editedUser.firstName}" maxlength="${util.Util.VARCHAR_SIZE}"/>
            <span class="help-inline">​#{error 'firstName'/}</span>
        </div>
    </div>
    <div class="control-group #{errorClassBootstrap 'lastName'/}">
        <label class="control-label" for="lastName">Last name</label>
        <div class="controls">
            <input name="lastName" type="text" value="${flash.lastName ?: editedUser.lastName}" maxlength="${util.Util.VARCHAR_SIZE}"/>
            <span class="help-inline">​#{error 'lastName'/}</span>
        </div>
    </div>
    #{if user != null && user.isAdmin}
        <div class="control-group #{errorClassBootstrap 'isAdmin'/}">
            <label class="control-label" for="isAdmin">Administrator</label>
            <div class="controls">
                <input name="isAdmin" type="checkbox" value="true" #{if (flash.isAdmin == null && editedUser.isAdmin) || flash.isAdmin}checked="checked"#{/if} />
                <span class="help-inline">​#{error 'isAdmin'/}</span>
            </div>
        </div>
    #{/if}
    <div class="form-actions">
        <a href="@{Users.view(editedUser.userName)}" class="btn" title="Go back to profile">Cancel</a>​
        <input type="submit" class="btn btn-primary" value="Save profile" title="Save profile"/>
    </div>
</fieldset>

#{/form}